<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="TOKN">﻿</span><span class="COMM">/*
<span class='line'>  2</span> Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
<span class='line'>  3</span> For licensing, see LICENSE.html or http://ckeditor.com/license
<span class='line'>  4</span> */</span><span class="WHIT">
<span class='line'>  5</span>
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @fileOverview Defines the {@link CKEDITOR.focusManager} class, which is used
<span class='line'>  8</span>  *		to handle the focus on editor instances..
<span class='line'>  9</span>  */</span><span class="WHIT">
<span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span>  * Manages the focus activity in an editor instance. This class is to be used
<span class='line'> 13</span>  * mainly by UI elements coders when adding interface elements to CKEditor.
<span class='line'> 14</span>  * @constructor
<span class='line'> 15</span>  * @param {CKEDITOR.editor} editor The editor instance.
<span class='line'> 16</span>  * @example
<span class='line'> 17</span>  */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="NAME">CKEDITOR.focusManager</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">editor</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">editor.focusManager</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">editor.focusManager</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span>
<span class='line'> 23</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 24</span> 	 * Indicates that the editor instance has focus.
<span class='line'> 25</span> 	 * @type Boolean
<span class='line'> 26</span> 	 * @example
<span class='line'> 27</span> 	 * alert( CKEDITOR.instances.editor1.focusManager.hasFocus );  // e.g "true"
<span class='line'> 28</span> 	 */</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">	</span><span class="NAME">this.hasFocus</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span>
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 32</span> 	 * Object used to hold private stuff.
<span class='line'> 33</span> 	 * @private
<span class='line'> 34</span> 	 */</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">	</span><span class="NAME">this._</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">		</span><span class="NAME">editor</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">editor</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span>
<span class='line'> 40</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span>
<span class='line'> 43</span> </span><span class="NAME">CKEDITOR.focusManager.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 46</span> 	 * Indicates that the editor instance has the focus.
<span class='line'> 47</span> 	 *
<span class='line'> 48</span> 	 * This function is not used to set the focus in the editor. Use
<span class='line'> 49</span> 	 * {@link CKEDITOR.editor#focus} for it instead.
<span class='line'> 50</span> 	 * @example
<span class='line'> 51</span> 	 * var editor = CKEDITOR.instances.editor1;
<span class='line'> 52</span> 	 * &lt;b>editor.focusManager.focus()&lt;/b>;
<span class='line'> 53</span> 	 */</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">	</span><span class="NAME">focus</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">this._.timer</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">			</span><span class="NAME">clearTimeout</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">this._.timer</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span>
<span class='line'> 59</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">this.hasFocus</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">			</span><span class="COMM">// If another editor has the current focus, we first "blur" it. In</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">			</span><span class="COMM">// this way the events happen in a more logical sequence, like:</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">			</span><span class="COMM">//		"focus 1" > "blur 1" > "focus 2"</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">			</span><span class="COMM">// ... instead of:</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">			</span><span class="COMM">//		"focus 1" > "focus 2" > "blur 1"</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.currentInstance</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">				</span><span class="NAME">CKEDITOR.currentInstance.focusManager.forceBlur</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span>
<span class='line'> 69</span> </span><span class="WHIT">			</span><span class="NAME">this.hasFocus</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">			</span><span class="NAME">this._.editor.fire</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">'focus'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 73</span>
<span class='line'> 74</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 75</span> 	 * Indicates that the editor instance has lost the focus. Note that this
<span class='line'> 76</span> 	 * functions acts asynchronously with a delay of 100ms to avoid subsequent
<span class='line'> 77</span> 	 * blur/focus effects. If you want the "blur" to happen immediately, use
<span class='line'> 78</span> 	 * the {@link #forceBlur} function instead.
<span class='line'> 79</span> 	 * @example
<span class='line'> 80</span> 	 * var editor = CKEDITOR.instances.editor1;
<span class='line'> 81</span> 	 * &lt;b>editor.focusManager.blur()&lt;/b>;
<span class='line'> 82</span> 	 */</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">	</span><span class="NAME">blur</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">focusManager</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span>
<span class='line'> 87</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">focusManager._.timer</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">			</span><span class="NAME">clearTimeout</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">focusManager._.timer</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span>
<span class='line'> 90</span> </span><span class="WHIT">		</span><span class="NAME">focusManager._.timer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">			</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">			</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">				</span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">focusManager._.timer</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">				</span><span class="NAME">focusManager.forceBlur</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">			</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 98</span>
<span class='line'> 99</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>100</span> 	 * Indicates that the editor instance has lost the focus. Unlike
<span class='line'>101</span> 	 * {@link #blur}, this function is synchronous, marking the instance as
<span class='line'>102</span> 	 * "blured" immediately.
<span class='line'>103</span> 	 * @example
<span class='line'>104</span> 	 * var editor = CKEDITOR.instances.editor1;
<span class='line'>105</span> 	 * &lt;b>editor.focusManager.forceBlur()&lt;/b>;
<span class='line'>106</span> 	 */</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">	</span><span class="NAME">forceBlur</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">this.hasFocus</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">			</span><span class="NAME">this.hasFocus</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">			</span><span class="NAME">this._.editor.fire</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="STRN">'blur'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>115</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span></pre></body></html>
